<!-- Copyright 2015 The Chromium Authors. All rights reserved.
     Use of this source code is governed by a BSD-style license that can be
     found in the LICENSE file. -->

<link rel="import" href="chrome://resources/html/polymer.html">

<link rel="import" href="chrome://resources/cr_elements/cr_input/cr_input.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html">

<link rel="import" href="../../components/display_manager_types.html">
<link rel="import" href="../../components/oobe_icons.html">
<link rel="import" href="../../components/behaviors/login_screen_behavior.html">
<link rel="import" href="../../components/behaviors/multi_step_behavior.html">
<link rel="import" href="../../components/behaviors/oobe_i18n_behavior.html">
<link rel="import" href="../../components/buttons/oobe_next_button.html">
<link rel="import" href="../../components/buttons/oobe_text_button.html">
<link rel="import" href="../../components/common_styles/common_styles.html">
<link rel="import" href="../../components/common_styles/oobe_dialog_host_styles.html">
<link rel="import" href="../../components/dialogs/oobe_adaptive_dialog.html">
<link rel="import" href="../../components/dialogs/oobe_loading_dialog.html">
<link rel="import" href="../../login_ui_tools.html">

<!--
  Password changed UI for the Gaia flow.
  Contains cards with a transition between them:
    1. Old password input form
    2. Warning about data loss
    3. Spinner with notice "Please wait"

  Example:
    <gaia-password-changed-element id="gaia-password-changed" hidden>
    </gaia-password-changed-element>

  Methods:
    'reset'      - reset element, sets in on the first screen and enables
                   buttons.
-->
<dom-module id="gaia-password-changed-element">
  <template>
    <style include="oobe-dialog-host-styles"></style>
    <oobe-adaptive-dialog role="dialog" for-step="password" id="passwordStep">
      <iron-icon slot="icon" icon="oobe-32:avatar"></iron-icon>
      <h1 slot="title">[[email]]</h1>
      <p slot="subtitle">
        [[i18nDynamic(locale, 'passwordChangedTitle')]]
      </p>
      <div slot="content" class="landscape-vertical-centered">
        <cr-input type="password" id="oldPasswordInput" required
            value="{{password_}}" invalid="{{passwordInvalid_}}"
            class="focus-on-show"
            placeholder="[[i18nDynamic(locale, 'oldPasswordHint')]]"
            error-message="[[i18nDynamic(locale, 'oldPasswordIncorrect')]]">
        </cr-input>
        <gaia-button id="forgotPasswordLink"
            on-click="onForgotPasswordClicked_" link>
          [[i18nDynamic(locale,'forgotOldPasswordButtonText')]]
        </gaia-button>
      </div>
      <div slot="bottom-buttons">
        <oobe-text-button id="cancel" on-click="onCancel_" text-key="cancel"
            border>
        </oobe-text-button>
        <oobe-next-button id="next" on-click="submit_" text-key="nextButtonText"
            inverse>
        </oobe-next-button>
      </div>
    </oobe-adaptive-dialog>

    <oobe-adaptive-dialog role="dialog" for-step="forgot" id="forgotPassword">
      <iron-icon slot="icon" icon="oobe-32:warning"></iron-icon>
      <h1 slot="title">[[email]]</h1>
      <p slot="subtitle">
        [[i18nDynamic(locale, 'passwordChangedProceedAnywayTitle')]]
      </p>
      <div slot="bottom-buttons">
        <oobe-text-button id="tryAgain" on-click="onTryAgainClicked_"
            class="focus-on-show" text-key="passwordChangedTryAgain">
        </oobe-text-button>
        <oobe-text-button id="proceedAnyway" on-click="onProceedClicked_"
            text-key="proceedAnywayButton" inverse>
        </oobe-text-button>
      </div>
    </oobe-adaptive-dialog>

    <oobe-loading-dialog id="progress" role="dialog" for-step="progress"
        title-key="gaiaLoading">
      <iron-icon slot="icon" icon="oobe-32:googleg"></iron-icon>
    </oobe-loading-dialog>
  </template>
  <script src="gaia_password_changed.js"></script>
</dom-module>
